const fs = require("fs");
const crypto = require("crypto");
const start = Date.now();
// 因为加入了文件的I/O  与浏览器端的不一样
process.env.UV_THREADPOOL_SIZE = 1; // 更改线程池数量
setTimeout(()=>{
    console.log("Timer 1 finished", 0);

})
setImmediate(()=>console.log("Immediate 1 finished"));
fs.readFile("../txt/input.txt",()=>{
    console.log("I/O finishied");
    console.log("-------------");
    setTimeout(()=>{
        console.log("Timer 2 finished")
    },0)
    setTimeout(()=>{
        console.log("Timer 3 finished")
    },3000)
    // 这步定时器会比timeout1先执行
    // 因为I/O
    setImmediate(()=>console.log("Immediate 2 finished"));
    // 这个immediate前面
    process.nextTick(()=>{
        console.log("Process.nextTrick")
    })

    crypto.pbkdf2('password','salt',100000,1024,'sha512',()=>{
        console.log(Date.now()-start,"passWord encrypted");
    });
    crypto.pbkdf2('password','salt',100000,1024,'sha512',()=>{
        console.log(Date.now()-start,"passWord encrypted");
    });
    crypto.pbkdf2('password','salt',100000,1024,'sha512',()=>{
        console.log(Date.now()-start,"passWord encrypted");
    });
    crypto.pbkdf2('password','salt',100000,1024,'sha512',()=>{
        console.log(Date.now()-start,"passWord encrypted");
    });
})